//
//  FinanceLogTableViewCell.m
//  Kjs-iOS
//
//  Created by 江伟 on 16/7/10.
//  Copyright © 2016年 jmhz. All rights reserved.
//

#import "FinanceLogTableViewCell.h"
#import "CommonUtil.h"
@interface FinanceLogTableViewCell ()
@property (nonatomic,weak) IBOutlet UILabel *amountNameLab;
@property (nonatomic,weak) IBOutlet UILabel *bondInvestNameLab;
@property (nonatomic,weak) IBOutlet UILabel *totalBondInvestIncomeNameLab;
@property (nonatomic,weak) IBOutlet UILabel *blockBlanceNameLab;

@end
@implementation FinanceLogTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.availablebalanceLab.adjustsFontSizeToFitWidth = YES;
    self.blockedBalanceLab.adjustsFontSizeToFitWidth = YES;
    self.bondInvestLab.adjustsFontSizeToFitWidth = YES;
    self.totalBondInvestIncomeLab.adjustsFontSizeToFitWidth = YES;
    self.amountLab.adjustsFontSizeToFitWidth = YES;
    self.gdBenefitModeLab.adjustsFontSizeToFitWidth = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (void)setLog:(FinanceLog *)log
{
    NSLog(@"log传进来了=%@",log);
    self.dateLab.text = [log.date componentsSeparatedByString:@" "][0];
    self.typeLab.text = [CommonUtil getLogTypeNameWithTpye:log.type];
    self.itemNameLab.text = log.itemName;
    self.gdAnnualizedBenefitRateLab.text = [NSString stringWithFormat:@"%.2lf％",log.gdAnnualizedBenefitRate*100];
    self.interestDaysLab.text = [NSString stringWithFormat:@"%d天",log.interestDays];
    self.gdBenefitModeLab.text = [CommonUtil getGdBenefitModeStrWithStrMode:log.gdBenefitMode];
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    formatter.numberStyle = NSNumberFormatterDecimalStyle;
    NSString *availablebalanceStr = [formatter stringFromNumber:[NSNumber numberWithDouble:[log.availablebalance doubleValue]]];
    NSString *blockedBalanceStr = [formatter stringFromNumber:[NSNumber numberWithDouble:[log.blockedBalance doubleValue]]];
    NSString *bondInvestStr = [formatter stringFromNumber:[NSNumber numberWithDouble:[log.bondInvest doubleValue]]];
    NSString *totalBondInvestIncomeStr = [formatter stringFromNumber:[NSNumber numberWithDouble:[log.totalBondInvestIncome doubleValue]]];
    NSString *amoutStr = [formatter stringFromNumber:[NSNumber numberWithDouble:[log.amount doubleValue]]];
    self.availablebalanceLab.text = [NSString stringWithFormat:@"¥%@元",availablebalanceStr];
    self.blockedBalanceLab.text = [NSString stringWithFormat:@"¥%@元",blockedBalanceStr];
    self.bondInvestLab.text = [NSString stringWithFormat:@"¥%@元",bondInvestStr];
    self.totalBondInvestIncomeLab.text = [NSString stringWithFormat:@"¥%@元",totalBondInvestIncomeStr];
    self.amountLab.text = [NSString stringWithFormat:@"¥%@元",amoutStr];
    self.orderPayModeNameLab.text = [CommonUtil getOrderPayModeNameWithMode:log.orderPayModeName];
    //如果是融资流水，字段名称变化
    if ([log.type containsString:@"zqrz"]) {
        self.amountNameLab.text = @"融资金额";
        
        self.bondInvestNameLab.text = @"待还本金";
        NSString *totalBondRaisePrincipleStill = [formatter stringFromNumber:[NSNumber numberWithDouble:[log.totalBondRaisePrincipleStill doubleValue]]];
        self.bondInvestLab.text = [NSString stringWithFormat:@"¥%@元",totalBondRaisePrincipleStill];
        
        self.totalBondInvestIncomeNameLab.text = @"累计已还利息";
        NSString *totalBondRaiseInterestRepay = [formatter stringFromNumber:[NSNumber numberWithDouble:[log.totalBondRaiseInterestRepay doubleValue]]];
        self.totalBondInvestIncomeLab.text = [NSString stringWithFormat:@"¥%@元",totalBondRaiseInterestRepay];
        
        self.blockBlanceNameLab.text = @"待还利息";
        NSString *totalBondRaiseInterestStill = [formatter stringFromNumber:[NSNumber numberWithDouble:[log.totalBondRaiseInterestStill doubleValue]]];
        self.blockedBalanceLab.text = [NSString stringWithFormat:@"¥%@元",totalBondRaiseInterestStill];
    }
}
@end
